package com.balabala.gym_user.controller.app;

import com.balabala.gym_enum.ResultEnum;
import com.balabala.gym_user.pojo.entity.User;
import com.balabala.gym_user.service.UserService;
import com.balabala.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 何涛
 * @Date: 2023/04/30/ 13:32
 * @description 前台用户接口
 */
@RestController
@RequestMapping("/app/user")
@Slf4j
@CrossOrigin
@Api(tags = "用户前台接口")
public class UserAppController {
    @Autowired
    UserService userService;
    @GetMapping("/oneLoginBySmsCode")
    @ApiOperation("验证码一键登录")
    public Result oneLoginBySmsCode(@RequestParam String phone,@RequestParam String code)
    {
        return Result.ok(ResultEnum.LOGIN_SUCCESS,userService.oneLoginBySmsCode(phone,code));
    }
    @GetMapping("/loginByWx")
    @ApiOperation("微信授权登录")
    public Result LoginByWx(@RequestParam String code)
    {
        return Result.ok(ResultEnum.LOGIN_SUCCESS,userService.loginByWx(code));
    }
    @ApiOperation("获取用户信息")
    @GetMapping("/getUserInfoByUserToken")
    public Result getUserInfoByUserToken(String userToken)
    {

        return Result.ok(ResultEnum.GENERALLY_SUCCESS,userService.getUserInfo(userToken));
    }

    @ApiOperation("查询用户个人信息")
    @GetMapping("/getUserDetailInfo")
    public Result getUserDetailInfo()
    {
        return Result.ok(userService.getUserDetailInfo());
    }
    @ApiOperation("修改用户详细信息")
    @PostMapping("updateUserDetailInfo")
    public Result getUserDetailInfo(@RequestBody User user)
    {
        log.info("正在修改用户信息，新的用户信息：{}",user);
        return Result.judge(userService.updateById(user));
    }
    @ApiOperation("查看用户团课信息")
    @GetMapping("getUserGroupLessons")
    public Result getUserGroupLessons()
    {

        //todo 待完善
        return Result.ok();
    }
    @ApiOperation("查看用户私教课程")
    @GetMapping("getUserPrivateLessons")
    public Result getUserPrivateLessons()
    {
        //todo 待完善
        return Result.ok();
    }
    @ApiOperation("查看系统消息")
    @GetMapping("getSystemMessage")
    public Result getSystemMessage()
    {
        //todo 待完善
        return Result.ok();
    }
    @ApiOperation("查看用户评论信息")
    @GetMapping ("getUserComments")
    public Result getUserComments()
    {
        //todo 待完善
        return Result.ok();
    }
    @ApiOperation("查看用户预约课程")
    @GetMapping("getUserBookingLessons")
    public Result getUserBookingLessons()
    {
        //todo 待完善
        return Result.ok();
    }





}
